<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <title th:text="${sectionName}"> - 论坛</title>
    <head th:insert="~{import :: head}"></head>

</head>
<body>
<div class="index-body">
    <div class="fixed-top" th:insert="~{navigation :: nav}"></div>
    <div class="container-fluid">
        <div class="row">
            <div class="col-lg-9 col-md-12 col-sm-12" >

                <div>
                    <h2><span th:text="${sectionName}"></span></h2>
                    <div th:if="${section == 'replies'}">
                        <a class="float-right media-left href" onclick="deleteAllNotifications()">全部清除</a>
                        <a class="float-right media-left href" onclick="markAllAsRead()">全部已读</a>
                    </div>
                </div>
                <hr>
                <div th:if="${section == 'index'}">
                    <div class="media" th:each="post : ${paginationDTO.data}">
                        <div class="media-body">
                            <h3 class="mt-0">
                                <a class="href" th:href="@{'/post/'+${post.id}}" th:text="${post.title}" ></a>
                            </h3>
                            <span class="text-desc"><span th:text="${post.commentCount}"></span> 回复 <span
                                    th:text="${post.viewCount}"></span> 浏览 <span th:text="${#dates.format(post.gmtCreate,'yy.MM.dd')}"></span>
                            <a th:href="@{'/publish/'+${post.id}}" class="post-menu" th:if="${session.user != null && session.user.id == post.creator}">
                                <svg class="bi bi-pen" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                <path fill-rule="evenodd" d="M5.707 13.707a1 1 0 0 1-.39.242l-3 1a1 1 0 0 1-1.266-1.265l1-3a1 1 0 0 1 .242-.391L10.086 2.5a2 2 0 0 1 2.828 0l.586.586a2 2 0 0 1 0 2.828l-7.793 7.793zM3 11l7.793-7.793a1 1 0 0 1 1.414 0l.586.586a1 1 0 0 1 0 1.414L5 13l-3 1 1-3z"/>
                                <path fill-rule="evenodd" d="M9.854 2.56a.5.5 0 0 0-.708 0L5.854 5.855a.5.5 0 0 1-.708-.708L8.44 1.854a1.5 1.5 0 0 1 2.122 0l.293.292a.5.5 0 0 1-.707.708l-.293-.293z"/>
                                <path d="M13.293 1.207a1 1 0 0 1 1.414 0l.03.03a1 1 0 0 1 .03 1.383L13.5 4 12 2.5l1.293-1.293z"/></svg>编辑
                            </a>
                                <a class="post-menu" th:data-id="${post.id}" th:onclick="'deletePost(\''+${post.id}+'\')'">
                        <input type="hidden" id="creator" th:value="${post.creator}">
                        <input type="hidden" id="userId" th:value="${session.user.id}">
                        <svg class="bi bi-trash" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                            <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
                            <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
                        </svg>删除
                    </a>

                        </span>

                        </div>
                    </div>
                    <nav aria-label="Page navigation example">
                        <ul class="pagination">
                            <li th:if="${paginationDTO.showFirstPage}" class="page-item">
                                <a class="page-link" aria-label="Previous" th:href="@{${section}(page=${1})}"><span aria-hidden="true">首页</span></a>
                            </li>
                            <li th:if="${paginationDTO.showPrevious}" class="page-item">
                                <a class="page-link" aria-label="Previous" th:href="@{${section}(page=${paginationDTO.page -1})}"><span aria-hidden="true">&lt;</span></a>
                            </li>
                            <li th:each="page: ${paginationDTO.pages}" th:class ="${paginationDTO.page == page}?'page-item active':'page-item'">
                                <a class ="page-link" th:href="@{${section}(page=${page})}" th:text="${page}"></a>
                            </li>
                            <li th:if="${paginationDTO.showNext}" class="page-item">
                                <a class="page-link" aria-label="Next" th:href="@{${section}(page=${paginationDTO.page +1})}"><span aria-hidden="true">&gt;</span></a>
                            </li>
                            <li th:if="${paginationDTO.showEndPage}" class="page-item">
                                <a class="page-link" aria-label="Next" th:href="@{${section}(page=${paginationDTO.totalPage})}"><span aria-hidden="true">尾页</span></a>
                            </li>
                        </ul>
                    </nav>
                </div>
                <div th:if="${section == 'comment'}">
                    <div class="media" th:each="comment : ${paginationDTO.data}">
                        <div class="media-body">
                            <h4 class="mt-0">
                                <span th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                                <span th:if="${comment.type == 1}">回复了帖子</span>
                                <span th:if="${comment.type == 2}">回复了评论</span>
                                <a class="href" th:href="@{'/post/'+${comment.postId}}" th:text="${comment.postTitle}"></a>
                            </h4>
                            <div class="comment-content" th:text="${comment.shortContent}"></div>
                            <div class="text-desc">
                                <a th:href="@{'/post/'+${comment.postId}}">查看详情</a>
                            </div>
                        </div>
                    </div>

                    <nav aria-label="Page navigation example">
                        <ul class="pagination">
                            <li th:if="${paginationDTO.showFirstPage}" class="page-item">
                                <a class="page-link" aria-label="Previous" th:href="@{'/profile/comment'(page=${1})}"><span aria-hidden="true">首页</span></a>
                            </li>
                            <li th:if="${paginationDTO.showPrevious}" class="page-item">
                                <a class="page-link" aria-label="Previous" th:href="@{'/profile/comment'(page=${paginationDTO.page -1})}"><span aria-hidden="true">&lt;</span></a>
                            </li>
                            <li th:each="page: ${paginationDTO.pages}" th:class="${paginationDTO.page == page}?'page-item active':'page-item'">
                                <a class="page-link" th:href="@{'/profile/comment'(page=${page})}" th:text="${page}"></a>
                            </li>
                            <li th:if="${paginationDTO.showNext}" class="page-item">
                                <a class="page-link" aria-label="Next" th:href="@{'/profile/comment'(page=${paginationDTO.page +1})}"><span aria-hidden="true">&gt;</span></a>
                            </li>
                            <li th:if="${paginationDTO.showEndPage}" class="page-item">
                                <a class="page-link" aria-label="Next" th:href="@{'/profile/comment'(page=${paginationDTO.totalPage})}"><span aria-hidden="true">尾页</span></a>
                            </li>
                        </ul>
                    </nav>
                </div>
                <div th:if="${section == 'replies'}">
                    <div class="media"  th:each="notification : ${paginationDTO.data}">
                        <div class="media-body">
                            <h4 class="mt-0">
                                <a class="href" th:text="${notification.notifierName}" th:href="@{'/user/'+${notification.notifier}}"></a>
                                <span th:text="${' '+ notification.typeName}"></span>
                                <a class="href" th:href="@{'/notification/'+${notification.id}}" th:text="${notification.outerTitle}" >
                                </a>
                                <span class="badge badge-danger badge-pill" th:if="${notification.status == 0}">未读</span>
                            </h4>
                        </div>
                    </div>
                    <nav aria-label="Page navigation example">
                        <ul class="pagination">
                            <li th:if="${paginationDTO.showFirstPage}" class="page-item">
                                <a class="page-link" aria-label="Previous" th:href="@{${section}(page=${1})}"><span aria-hidden="true">首页</span></a>
                            </li>
                            <li th:if="${paginationDTO.showPrevious}" class="page-item">
                                <a class="page-link" aria-label="Previous" th:href="@{${section}(page=${paginationDTO.page -1})}"><span aria-hidden="true">&lt;</span></a>
                            </li>
                            <li th:each="page: ${paginationDTO.pages}" th:class ="${paginationDTO.page == page}?'page-item active':'page-item'">
                                <a class ="page-link" th:href="@{${section}(page=${page})}" th:text="${page}"></a>
                            </li>
                            <li th:if="${paginationDTO.showNext}" class="page-item">
                                <a class="page-link" aria-label="Next" th:href="@{${section}(page=${paginationDTO.page +1})}"><span aria-hidden="true">&gt;</span></a>
                            </li>
                            <li th:if="${paginationDTO.showEndPage}" class="page-item">
                                <a class="page-link" aria-label="Next" th:href="@{${section}(page=${paginationDTO.totalPage})}"><span aria-hidden="true">尾页</span></a>
                            </li>
                        </ul>
                    </nav>
                </div>
            </div>
            <div class="col-lg-3 col-md-12 col-sm-12" >
                <div class="list-group">
                    <a href="/profile/index" th:class="'list-group-item list-group-item-action '+${section == 'index'?'active':''}">
                        我的发帖
                    </a>
                    <a href="/profile/comment" th:class="'list-group-item list-group-item-action '+${section == 'comment'?'active':''}">
                        我的回复
                    </a>
                    <a href="/profile/replies" th:class="'list-group-item list-group-item-action '+${section == 'replies'?'active':''}">
                        我的通知<span class="badge badge-danger badge-pill" th:if="${session.unreadCount!=0}" th:text="${session.unreadCount}"></span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>